package com.gbq.qimo.servlet;

import com.gbq.qimo.pojo.Student;
import com.gbq.qimo.service.StudentService;
import com.gbq.qimo.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName UpdateStudentServlet
 * @Description TODO
 * @Author guobenqi
 * @Date 2021/5/29 21:43
 */
@WebServlet("/findStudentById")
public class FindstudentByIdServlet extends HttpServlet {
    private StudentService studentService = new StudentServiceImpl();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      String id = request.getParameter("id");
        System.out.println(id);
        Student student = studentService.findStudentById(Integer.parseInt(id));
        request.setAttribute("student",student);
        request.getRequestDispatcher("/update.jsp").forward(request,response);

    }
}
